<?php


namespace App\Tool;


use Nette\Reflection\ClassType;

class Annotation
{

    /**
     * 根据请求路由获取@里面的数据
     * Create by Peter
     * 2020/05/25 13:50:09
     * Email:904801074@qq.com
     * @param $name
     * @return \Nette\Reflection\IAnnotation|null
     */
    static function getAnnotationByRoute($name){

        $route = request()->route();

        $controller = $route->action['controller'];

        $c = explode('@', $controller);

        $class = new ClassType($c[0]);

        $data = $class->getMethod($c[1])->getAnnotation($name);


        return $data;

    }

}
